package com.songcha.library_database_douyue

import android.app.Application
import android.content.Context
import com.songcha.library_database_douyue.greendao.DaoMaster
import com.songcha.library_database_douyue.greendao.DaoSession
import com.songcha.library_database_douyue.helper.MyDaoOpenHelper

class LibraryDatabaseDouyueApplication {
    companion object{

        private lateinit var mContext: Application
        private lateinit var mSession: DaoSession

        @JvmStatic
        fun init(context: Application){
            mContext=context

            val devOpenHelper =  MyDaoOpenHelper(mContext, "douyue.db")
            val db = devOpenHelper.writableDatabase
            val daoMaster =  DaoMaster(db)
            mSession = daoMaster.newSession()

        }

        @JvmStatic
        fun getContext(): Context {
            return mContext
        }

        fun getDaoSession():DaoSession{
            return mSession
        }
    }
}